#ifndef CPU_ALT_H
#define CPU_ALT_H

#include "CPU_Ready.h"
#include "types.h"

pos_t CPU_Alt(struct Agent_Var* agent)
{
    pos_t ret = 0;
    t1B cond = READ_CODE(agent,t1B);
    pos_t jump_pos = READ_CODE(agent,pos_t);
    switch(cond)
    {
        case JC_NC:
            ret = jump_pos;
            break;
        case JC_EQUAL:
            CPU_Cmp(agent);
            if(agent->condition & CM_EQUAL) ret = jump_pos;
            break;
        case JC_NEQUAL:
            CPU_Cmp(agent);
            if(!(agent->condition & CM_EQUAL)) ret = jump_pos;
            break;
        case JC_GREATER:
            CPU_Cmp(agent);
            if(agent->condition & CM_GREATER) ret = jump_pos;
            break;
        case JC_LOWER:
            CPU_Cmp(agent);
            if(agent->condition & CM_LOWER) ret = jump_pos;
            break;
        case JC_READY:
            CPU_Ready(agent);
            if(agent->condition & CM_READY) ret = jump_pos;
            break;

        default:
            break;
    }

    return ret;
}

#endif
